/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.zimbra.client.ZMailbox;
/*     */ import com.zimbra.client.ZMessage;
/*     */ import com.zimbra.common.calendar.WellKnownTimeZones;
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import com.zimbra.soap.account.message.ModifyPrefsRequest;
/*     */ import com.zimbra.soap.account.message.ModifyPrefsResponse;
/*     */ import com.zimbra.soap.account.type.Pref;
/*     */ import com.zimbra.soap.mail.message.CreateMountpointRequest;
/*     */ import com.zimbra.soap.mail.message.CreateMountpointResponse;
/*     */ import com.zimbra.soap.mail.message.FolderActionRequest;
/*     */ import com.zimbra.soap.mail.message.FolderActionResponse;
/*     */ import com.zimbra.soap.mail.message.GetMsgRequest;
/*     */ import com.zimbra.soap.mail.message.GetMsgResponse;
/*     */ import com.zimbra.soap.mail.type.ActionGrantSelector;
/*     */ import com.zimbra.soap.mail.type.FolderActionSelector;
/*     */ import com.zimbra.soap.mail.type.InviteWithGroupInfo;
/*     */ import com.zimbra.soap.mail.type.MsgSpec;
/*     */ import com.zimbra.soap.mail.type.MsgWithGroupInfo;
/*     */ import com.zimbra.soap.mail.type.NewMountpointSpec;
/*     */ import java.io.File;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Date;
/*     */ import junit.framework.TestCase;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestInvite
/*     */   extends TestCase
/*     */ {
/*  52 */   private SoapProvisioning prov = null;
/*  53 */   private static String NAME_PREFIX = "TestInvite";
/*  54 */   private static String USER_NAME = "user1";
/*  55 */   private static String ORGANIZER = "tiorganizer";
/*  56 */   private static String ATTENDEE = "tiattendee";
/*  57 */   private static String DELEGATE = "tidelegate";
/*     */   
/*     */   public void testBug86864DelegateInboxInviteLooksLikeInvite() throws Exception {
/*  60 */     TestUtil.createAccount(ORGANIZER);
/*  61 */     Account attendee = TestUtil.createAccount(ATTENDEE);
/*  62 */     Account delegate = TestUtil.createAccount(DELEGATE);
/*  63 */     ZMailbox mboxOrganizer = TestUtil.getZMailbox(ORGANIZER);
/*  64 */     ZMailbox mboxAttendee = TestUtil.getZMailbox(ATTENDEE);
/*  65 */     ZMailbox mboxDelegate = TestUtil.getZMailbox(DELEGATE);
/*  66 */     String subject = NAME_PREFIX + " for testing treatment at delegate inbox";
/*  67 */     Date startDate = new Date(System.currentTimeMillis() + 86400000L);
/*  68 */     Date endDate = new Date(startDate.getTime() + 3600000L);
/*     */     
/*  70 */     String calendarId = Integer.valueOf(10).toString();
/*  71 */     FolderActionSelector action = new FolderActionSelector(calendarId, "grant");
/*  72 */     ActionGrantSelector grant = new ActionGrantSelector("rwidxa", "usr");
/*  73 */     grant.setDisplayName(delegate.getName());
/*  74 */     grant.setPassword("");
/*  75 */     action.setGrant(grant);
/*  76 */     FolderActionRequest folderActionReq = new FolderActionRequest(action);
/*  77 */     FolderActionResponse folderActionResp = (FolderActionResponse)mboxAttendee.invokeJaxb(folderActionReq);
/*  78 */     assertNotNull("null FolderAction Response used to share folder", folderActionResp);
/*     */     
/*  80 */     ModifyPrefsRequest modPrefsReq = new ModifyPrefsRequest();
/*  81 */     Pref fwdInvitesPref = Pref.createPrefWithNameAndValue("zimbraPrefCalendarForwardInvitesTo", delegate.getName());
/*     */     
/*  83 */     modPrefsReq.addPref(fwdInvitesPref);
/*  84 */     Pref noAutoAddPref = Pref.createPrefWithNameAndValue("zimbraPrefCalendarAutoAddInvites", Boolean.FALSE.toString().toUpperCase());
/*     */     
/*  86 */     modPrefsReq.addPref(noAutoAddPref);
/*  87 */     ModifyPrefsResponse modPrefsResp = (ModifyPrefsResponse)mboxAttendee.invokeJaxb(modPrefsReq);
/*  88 */     assertNotNull("null ModifyPrefs Response for forwarding calendar invites/no auto-add", modPrefsResp);
/*     */     
/*  90 */     NewMountpointSpec mpSpec = new NewMountpointSpec("Shared Calendar");
/*  91 */     mpSpec.setFlags("#");
/*  92 */     mpSpec.setRemoteId(Integer.valueOf(10));
/*  93 */     mpSpec.setColor(Byte.valueOf((byte)4));
/*  94 */     mpSpec.setOwnerId(attendee.getId());
/*  95 */     mpSpec.setFolderId(Integer.valueOf(1).toString());
/*  96 */     mpSpec.setDefaultView(MailItem.Type.APPOINTMENT.toString());
/*  97 */     CreateMountpointRequest createMpReq = new CreateMountpointRequest(mpSpec);
/*  98 */     CreateMountpointResponse createMpResp = (CreateMountpointResponse)mboxDelegate.invokeJaxb(createMpReq);
/*  99 */     assertNotNull("null ModifyPrefs Response for forwarding calendar invites", createMpResp);
/*     */     
/* 101 */     TestUtil.createAppointment(mboxOrganizer, subject, attendee.getName(), startDate, endDate);
/* 102 */     ZMessage inviteMsg = TestUtil.waitForMessage(mboxDelegate, "in:inbox " + subject);
/* 103 */     assertNotNull("null inviteMsg in delegate inbox", inviteMsg);
/*     */     
/* 105 */     MsgSpec msgSpec = new MsgSpec(inviteMsg.getId());
/* 106 */     msgSpec.setWantHtml(Boolean.valueOf(true));
/* 107 */     msgSpec.setNeedCanExpand(Boolean.valueOf(true));
/* 108 */     msgSpec.setMaxInlinedLength(Integer.valueOf(250000));
/* 109 */     GetMsgRequest getMsgReq = new GetMsgRequest(msgSpec);
/* 110 */     GetMsgResponse getMsgResp = (GetMsgResponse)mboxDelegate.invokeJaxb(getMsgReq);
/* 111 */     assertNotNull("null GetMsgResponse in delegate inbox", getMsgResp);
/* 112 */     MsgWithGroupInfo msg = getMsgResp.getMsg();
/* 113 */     assertNotNull("null message in GetMsgResponse in delegate inbox", msg);
/* 114 */     InviteWithGroupInfo invite = msg.getInvite();
/* 115 */     assertNotNull("null invite in message in GetMsgResponse in delegate inbox regression to Bug 86864?", invite);
/*     */   }
/*     */   
/*     */   public void setUp() throws Exception
/*     */   {
/* 120 */     if (!TestUtil.fromRunUnitTests) {
/* 121 */       TestUtil.cliSetup();
/* 122 */       String tzFilePath = LC.timezone_file.value();
/* 123 */       File tzFile = new File(tzFilePath);
/* 124 */       WellKnownTimeZones.loadFromFile(tzFile);
/*     */     }
/* 126 */     if (this.prov == null) {
/* 127 */       this.prov = TestUtil.newSoapProvisioning();
/*     */     }
/* 129 */     tearDown();
/*     */   }
/*     */   
/*     */   public void tearDown() throws Exception
/*     */   {
/* 134 */     if (this.prov == null) {
/* 135 */       this.prov = TestUtil.newSoapProvisioning();
/*     */     }
/* 137 */     TestUtil.deleteAccount(ORGANIZER);
/* 138 */     TestUtil.deleteAccount(ATTENDEE);
/* 139 */     TestUtil.deleteAccount(DELEGATE);
/*     */   }
/*     */   
/*     */   public static void main(String[] args)
/*     */     throws Exception
/*     */   {
/*     */     try
/*     */     {
/* 147 */       TestUtil.runTest(TestInvite.class);
/*     */     } catch (Exception e) {
/* 149 */       System.out.println(e.getMessage());
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestInvite.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */